<template>
  <div id="LabSampleProcessByCodeReceipt">
    <Breadcrumb :content="content" v-if="false"></Breadcrumb>
    <Splitpanes style="height: 100%">
      <Pane size="30">
        <vxe-toolbar perfect>
          <template #buttons>
            <div class="smallToolTitle">交接单列表</div>
            <vxe-button type="text" class="button button-blue" icon="vxe-icon-refresh" content="刷新" :loading="showLoading" @click="handleSearch"></vxe-button>
          </template>
        </vxe-toolbar>

        <div class="modulTable">
          <vxe-table ref="unqualifiedTable" border="inner" height="auto" class="mytable-scrollbar" :loading="showLoading" :data="deliveryReceiptlist" @current-change="moduleRowClick" :row-config="{ isCurrent: true, isHover: true }" :keyboard-config="{
                isArrow: true,
                isTab: true,
                isEdit: true
              }" resizable show-overflow>
            <vxe-column type="checkbox" width="30" align="center"></vxe-column>
            <vxe-column type="seq" title="序号" width="30"></vxe-column>
            <vxe-column field="batchNo" title="批次号" min-width="110"> </vxe-column>
            <vxe-column field="handoverPersonNa" title="交接人" width="60"> </vxe-column>
            <vxe-column field="receiverNa" title="接收人" width="60"> </vxe-column>
            <vxe-column field="handoverTime" title="交接时间" width="140"> </vxe-column>
            <vxe-column field="quantity" title="标本数量" width="90"> </vxe-column>
          </vxe-table>
        </div>
      </Pane>
      <!-- 明细 -->
      <Pane size="70">
        <LabSampleProcessByCodeReceiptDel ref="refUnqualifiedReason"></LabSampleProcessByCodeReceiptDel>
      </Pane>
    </Splitpanes>
  </div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
import { Splitpanes, Pane } from 'splitpanes';
import LabSampleProcessByCodeReceiptDel from './LabSampleProcessByCodeReceiptDel.vue';
import Breadcrumb from '../../../components/Breadcrumb.vue';
import VxePulldownSelection from '../../../components/VxePulldownSelection.vue';
import VxePulldownSelectIconfont from '../../../components/VxePulldownSelectIconfont.vue';
import { VXETable } from 'vxe-table';
import { VxeMessage, VxeNotifyType } from '../../../utils/CommonMessage';
import { AppStore } from '../../../stores/store';
import SelectByDepList from '@/components/SelectByDepList.vue';
import SelectIcon from '../../../components/SelectIcon.vue';
import { funBdsJsResult } from '@/utils/Expression'; //函数公式
import SelectDataGrid from '@/components/SelectDataGrid.vue';

let store = AppStore();
let { proxy }: any = getCurrentInstance();

// 获取屏幕宽度
let conWidth = ref(document.documentElement.clientWidth);

// 子组件ref名称
let refselectIcon = ref(null);

// 页面标题
let content = ref('交接单');
// 用户输入关键字
let keywords = ref('');

// 加载中 loading效果状态
let showLoading = ref(false); //刷新

//**判断为空*/
let IsEmpty = (value: any) => {
  if (value === undefined || value === '' || value === null) {
    return true;
  }
  if (JSON.stringify(value) === '{}') {
    return true;
  }
  return false;
};

onMounted(() => {
  getLabDeliveryReceiptlist();
});

defineExpose({ initPageReceipt });
let code = ref('');
let processAttributeList = reactive([]);
let type = '';
function initPageReceipt(refData: any) {
  if (refData !== null) {
    code = refData.code;
    processAttributeList = refData.refAttributeList;
    type = refData.type;
    getLabDeliveryReceiptlist();

  }
}

let refUnqualifiedReason: any = ref(null);
// 点击行
function moduleRowClick({ row, rowIndex }) {
  let $Xtable = proxy.$refs.unqualifiedTable;
  $Xtable.setCurrentRow(row);
  refUnqualifiedReason.value.initPage(row);
}

// 表格规则
let formRule = ref({
  unqualifiedName: [
    {
      required: true,
      message: '请输入不合格组名称',
      trigger: 'blur'
    }
  ]
});
// 模块功能表格数据
let deliveryReceiptlist: any = reactive([]);
// 请求表格数据
function getLabDeliveryReceiptlist() {
  showLoading.value = true;
  let pageParam = {
    params: {
      keywords: keywords.value,
      type: type
    }
  };
  deliveryReceiptlist.length = 0; //放入数据前清空数组
  proxy.$http.get('/lab/delivery/receipt/getLabDeliveryReceiptlist', pageParam).then((res: any) => {
    if (res.status.code === 200) {
      showLoading.value = false;
      // console.log('模块数据列表', res.status.code);
      deliveryReceiptlist.push(...res.data);
      moduleRowClick({ row: deliveryReceiptlist[0], rowIndex: 0 });
      // VXETable.modal.message({ content: res.status.msg, status: 'success' });
    } else {
      VXETable.modal.message({ content: res.status.msg, status: 'error' });
      return;
    }
  });
}
// 点击刷新
function handleSearch() {
  getLabDeliveryReceiptlist();
}
let unqualifiedTable = ref();
// 关键字搜索
function search() {
  getLabDeliveryReceiptlist();
}

function keyup(e: any) {
  if (e.$event.code == 'Enter') {
    search();
  }
}
</script>
<style lang="scss" scoped>
#LabSampleProcessByCodeReceipt {
  height: 100%;
  width: 100%;

  // 左边表格
  .modulTable {
    height: calc(100% - 40px);
    background-color: $base-white;
  }
}
</style>
